package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.semanticanalyzer.analyzecontext.expressiondesc.ExpressionDescribe;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextreplacer.ParseContextReplacer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;

/**
 * 表达式解析内容
 * @author zwd
 *
 */
public class ExpressionContext extends BaseExpressionParseContext{
	
	//LoginExpressionOrContext
	private BaseExpressionParseContext expression;
	
	public BaseExpressionParseContext getExpression() {
		return expression;
	}

	public void setExpression(BaseExpressionParseContext expression) {
		this.expression = expression;
	}
	
	@Override
	public String toString() {
		return expression.toString();
	}
	
	@Override
	protected void walkChild(ParseContextWalker walker) {
		walkExpression(walker, expression);
	}

	@Override
	public void walkChildAndReplace(ParseContextReplacer replacer) {
		if(replacer.isChildsReplaceable(expression)){
			expression = replacer.createReplaceParseContext();
		}else{
			expression.walkChildAndReplace(replacer);
		}
	}
	
	@Override
	protected ExpressionDescribe createExpressionDesc() throws SemanticAnalyzerException {
		return expression.createExpressionDesc(getSchemas());
	}

}
